package com.read.common.exception;

import com.read.common.response.RespEnum;
import com.read.common.response.RespResult;
import com.read.util.RespUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author sh-sunb6
 * @description 全局异常
 * @date 2019-02-20 11:17
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = Exception.class)
    public RespResult handle(Exception e){
        e.printStackTrace();
        return RespUtil.error(RespEnum.INTERNAL_ERROR);
    }

    @ExceptionHandler(value = TokenException.class)
    public RespResult handleToken(TokenException te){
        te.printStackTrace();
        return RespUtil.error(te.getRespEnum());
    }

}
